//
//  HSHomeWorkTableViewCell.swift
//  HomeSchoolDemo
//
//  Created by rimi on 16/10/8.
//  Copyright © 2016年 黄华强. All rights reserved.
//

import UIKit

class HSHomeWorkTableViewCell: UITableViewCell {

    var hwTitle:UILabel!
    var teachNameLabel:UILabel!
    var subjectsButton:UIButton!
    var timeLabel:UILabel!
    var stateImageView:UIImageView!
    
    
    var model:HSHomeWorkTableModel? {
        didSet{
            hwTitle.text = model?.hw_title
            teachNameLabel.text = model?.hw_tName
            subjectsButton.setTitle(model?.courseName, for: .normal)
            timeLabel.text = model?.hw_createDate
            
            if model?.subStatus == 1 {
                stateImageView.image = UIImage(named: "hw_base_no_commit")
            } else {
                if model?.checkStatus == 1 {
                    stateImageView.image = UIImage(named: "hw_base_commit")
                } else {
                    stateImageView.image = UIImage(named: "hw_base_responses")
                }
            }
            
            
            
        }
    }
    /*
     checkStatus = 1;
     courseName = "\U5916\U8bed";
     "hw_courseId" = 1079132;
     "hw_createDate" = "2016-07-30 09:17:08.0";
     "hw_id" = 17;
     "hw_tId" = 1;
     "hw_tName" = "\U8001\U5e081";
     "hw_title" = "\U4f5c\U4e1a\U6807\U9898";
     subStatus = 1;
     */

    
        
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        hwTitle = UILabel(frame: CGRect(x: 12, y: 8, width: 100, height: 20))
        hwTitle.text = "作业标题"
        hwTitle.font = UIFont.systemFont(ofSize: UIScreen.main.bounds.width * 0.04)
        contentView.addSubview(hwTitle)
        
        teachNameLabel = UILabel(frame: CGRect(x: UIScreen.main.bounds.width * 0.5, y: 8, width: UIScreen.main.bounds.width * 0.25, height: 20))
        teachNameLabel.text = "王老师"
        teachNameLabel.textAlignment = NSTextAlignment.right
        teachNameLabel.font = UIFont.systemFont(ofSize: UIScreen.main.bounds.width * 0.035)
        contentView.addSubview(teachNameLabel)
        
        subjectsButton = UIButton(frame: CGRect(x: 12, y: 36, width: 36, height: 16))
        subjectsButton.layer.cornerRadius = 8
        subjectsButton.setTitle("数学", for: .normal)
        subjectsButton.setTitleColor(#colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1), for: .normal)
        subjectsButton.titleLabel?.font = UIFont.systemFont(ofSize: UIScreen.main.bounds.width * 0.03)
        subjectsButton.isUserInteractionEnabled = false
        subjectsButton.layer.borderColor = #colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1).cgColor
        subjectsButton.layer.borderWidth = 1
        contentView.addSubview(subjectsButton)
        
        timeLabel = UILabel(frame: CGRect(x: UIScreen.main.bounds.width * 0.4, y: 40, width: UIScreen.main.bounds.width * 0.35, height: 20))
        timeLabel.textAlignment = NSTextAlignment.right
        timeLabel.textColor = #colorLiteral(red: 0.6980392157, green: 0.6980392157, blue: 0.6980392157, alpha: 1)
        timeLabel.text = "2016-10-10 08:08"
        timeLabel.font = UIFont.systemFont(ofSize: UIScreen.main.bounds.width * 0.03)
        contentView.addSubview(timeLabel)
        
        stateImageView = UIImageView(frame: CGRect(origin: CGPoint(x: UIScreen.main.bounds.width * 0.8, y: 6), size: CGSize(width: 56, height: 56)))
        stateImageView.image = UIImage(named: "已批改3")
        contentView.addSubview(stateImageView)
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

    }

}
